#include <fftw3-mpi.h>
     
     int main(int argc, char **argv)
     {
         const ptrdiff_t N0 = 32, N1 = 32, N2 = 32;
         fftw_plan plan;
         fftw_complex *z;
         ptrdiff_t alloc_local, local_n0, local_0_start, i, j, k;
     
         MPI_Init(&argc, &argv);
         fftw_mpi_init();
     
         /* get local data size and allocate */
         alloc_local = fftw_mpi_local_size_3d(N0, N1, N2, MPI_COMM_WORLD,
                                              &local_n0, &local_0_start);
         z = fftw_alloc_complex(alloc_local);
     
         /* create plan for in-place forward DFT */
         plan = fftw_mpi_plan_dft_3d(N0, N1, N2, z, z, MPI_COMM_WORLD,
                                     FFTW_FORWARD, FFTW_PATIENT);
     
         /* initialize data to some function my_function(x,y) */
         //for (i = 0; i < local_n0; ++i) for (j = 0; j < N1; ++j) for (k = 0; k < N2; ++k)
         //   z[k + N1*(j + N2*i)] = 0; //my_function(local_0_start + i, j);
     
         /* compute transforms, in-place, as many times as desired */
         for (i = 0; i < 10000; i++) fftw_execute(plan);
         fftw_destroy_plan(plan);
     
         MPI_Finalize();
     }
